\hypertarget{compressor_8h}{}\doxysection{compressor.\+h File Reference}
\label{compressor_8h}\index{compressor.h@{compressor.h}}
{\ttfamily \#include \char`\"{}bit\+\_\+operations.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}schc.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int8\+\_\+t \mbox{\hyperlink{compressor_8h_a15002a02e9cae01e5629cb2d474fe482}{set\+\_\+rule\+\_\+id}} (struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$schc\+\_\+rule, uint8\+\_\+t $\ast$data)
\item 
uint8\+\_\+t \mbox{\hyperlink{compressor_8h_a4fd03f3acd56b4bf55fc4c8e48567ab7}{schc\+\_\+compressor\+\_\+init}} (uint8\+\_\+t src\mbox{[}16\mbox{]})
\begin{DoxyCompactList}\small\item\em Initializes the S\+C\+HC compressor. \end{DoxyCompactList}\item 
int16\+\_\+t \mbox{\hyperlink{compressor_8h_a0b9e16aa71f4074dec7245991fdebcdb}{schc\+\_\+compress}} (uint8\+\_\+t $\ast$data, uint16\+\_\+t total\+\_\+length, \mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$buf, uint32\+\_\+t device\+\_\+id, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} dir, struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$$\ast$schc\+\_\+rule)
\begin{DoxyCompactList}\small\item\em Compresses a Co\+A\+P/\+U\+D\+P/\+IP packet. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8h_aaf76c0525a94eecb1f694ba09b435c49}{get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+reliability\+\_\+mode}} (struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$schc\+\_\+rule, \mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}} mode, uint32\+\_\+t device\+\_\+id)
\item 
struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8h_aad3e564426f2baa62e653ebdb5635e2e}{get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+rule\+\_\+id}} (uint8\+\_\+t $\ast$rule\+\_\+id, uint32\+\_\+t device\+\_\+id)
\item 
uint16\+\_\+t \mbox{\hyperlink{compressor_8h_a8af6027989d3e39cdcc37f16ff38d7ff}{schc\+\_\+decompress}} (\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$bit\+\_\+arr, uint8\+\_\+t $\ast$buf, uint32\+\_\+t device\+\_\+id, uint16\+\_\+t total\+\_\+length, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} dir)
\begin{DoxyCompactList}\small\item\em Construct the header from the layered set of rules. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{compressor_8h_aaf76c0525a94eecb1f694ba09b435c49}\label{compressor_8h_aaf76c0525a94eecb1f694ba09b435c49}} 
\index{compressor.h@{compressor.h}!get\_schc\_rule\_by\_reliability\_mode@{get\_schc\_rule\_by\_reliability\_mode}}
\index{get\_schc\_rule\_by\_reliability\_mode@{get\_schc\_rule\_by\_reliability\_mode}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{get\_schc\_rule\_by\_reliability\_mode()}{get\_schc\_rule\_by\_reliability\_mode()}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}}$\ast$ get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+reliability\+\_\+mode (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$}]{schc\+\_\+rule,  }\item[{\mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}}}]{mode,  }\item[{uint32\+\_\+t}]{device\+\_\+id }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compressor_8h_aad3e564426f2baa62e653ebdb5635e2e}\label{compressor_8h_aad3e564426f2baa62e653ebdb5635e2e}} 
\index{compressor.h@{compressor.h}!get\_schc\_rule\_by\_rule\_id@{get\_schc\_rule\_by\_rule\_id}}
\index{get\_schc\_rule\_by\_rule\_id@{get\_schc\_rule\_by\_rule\_id}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{get\_schc\_rule\_by\_rule\_id()}{get\_schc\_rule\_by\_rule\_id()}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}}$\ast$ get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+rule\+\_\+id (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rule\+\_\+id,  }\item[{uint32\+\_\+t}]{device\+\_\+id }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compressor_8h_a0b9e16aa71f4074dec7245991fdebcdb}\label{compressor_8h_a0b9e16aa71f4074dec7245991fdebcdb}} 
\index{compressor.h@{compressor.h}!schc\_compress@{schc\_compress}}
\index{schc\_compress@{schc\_compress}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{schc\_compress()}{schc\_compress()}}
{\footnotesize\ttfamily int16\+\_\+t schc\+\_\+compress (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{data,  }\item[{uint16\+\_\+t}]{total\+\_\+length,  }\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{dst,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{dir,  }\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$$\ast$}]{schc\+\_\+rule }\end{DoxyParamCaption})}



Compresses a Co\+A\+P/\+U\+D\+P/\+IP packet. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the original packet \\
\hline
{\em total\+\_\+length} & the length of the packet \\
\hline
{\em dst} & pointer to the bit array object, where the compressed packet will be stored. Can later be passed to fragmenter \\
\hline
{\em device\+\_\+id} & the device id to find a rule for \\
\hline
{\em direction} & the direction of the flow UP\+: L\+P\+W\+AN to I\+Pv6 or D\+O\+WN\+: I\+Pv6 to L\+P\+W\+AN \\
\hline
{\em device\+\_\+type} & the device type\+: N\+E\+T\+W\+O\+R\+K\+\_\+\+G\+A\+T\+E\+W\+AY or D\+E\+V\+I\+CE \\
\hline
{\em schc\+\_\+rule} & a pointer to a schc rule struct to return the rule that was found\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
length the length of the compressed packet -\/1 on a memory overflow
\end{DoxyReturn}
\begin{DoxyNote}{Note}
the compressor will only look for rules configured with the N\+O\+T\+\_\+\+F\+R\+A\+G\+M\+E\+N\+T\+ED reliability mode 
\end{DoxyNote}
\mbox{\Hypertarget{compressor_8h_a4fd03f3acd56b4bf55fc4c8e48567ab7}\label{compressor_8h_a4fd03f3acd56b4bf55fc4c8e48567ab7}} 
\index{compressor.h@{compressor.h}!schc\_compressor\_init@{schc\_compressor\_init}}
\index{schc\_compressor\_init@{schc\_compressor\_init}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{schc\_compressor\_init()}{schc\_compressor\_init()}}
{\footnotesize\ttfamily uint8\+\_\+t schc\+\_\+compressor\+\_\+init (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{src\mbox{[}16\mbox{]} }\end{DoxyParamCaption})}



Initializes the S\+C\+HC compressor. 


\begin{DoxyParams}{Parameters}
{\em node\+\_\+ip} & a pointer to the source it\textquotesingle{}s ip address\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
error error codes on error 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8h_a8af6027989d3e39cdcc37f16ff38d7ff}\label{compressor_8h_a8af6027989d3e39cdcc37f16ff38d7ff}} 
\index{compressor.h@{compressor.h}!schc\_decompress@{schc\_decompress}}
\index{schc\_decompress@{schc\_decompress}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{schc\_decompress()}{schc\_decompress()}}
{\footnotesize\ttfamily uint16\+\_\+t schc\+\_\+decompress (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{bit\+\_\+arr,  }\item[{uint8\+\_\+t $\ast$}]{buf,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{uint16\+\_\+t}]{total\+\_\+length,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{dir }\end{DoxyParamCaption})}



Construct the header from the layered set of rules. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the received data \\
\hline
{\em buf} & pointer where to save the decompressed packet \\
\hline
{\em device\+\_\+id} & the device its id \\
\hline
{\em total\+\_\+length} & the total length of the received data \\
\hline
{\em direction} & the direction of the flow (UP\+: L\+P\+W\+AN to I\+Pv6, D\+O\+WN\+: I\+Pv6 to L\+P\+W\+AN)\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
length length of the newly constructed packet 0 the rule was not found 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8h_a15002a02e9cae01e5629cb2d474fe482}\label{compressor_8h_a15002a02e9cae01e5629cb2d474fe482}} 
\index{compressor.h@{compressor.h}!set\_rule\_id@{set\_rule\_id}}
\index{set\_rule\_id@{set\_rule\_id}!compressor.h@{compressor.h}}
\doxysubsubsection{\texorpdfstring{set\_rule\_id()}{set\_rule\_id()}}
{\footnotesize\ttfamily int8\+\_\+t set\+\_\+rule\+\_\+id (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$}]{schc\+\_\+rule,  }\item[{uint8\+\_\+t $\ast$}]{data }\end{DoxyParamCaption})}

